//
//  BackupsSwitchView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/27.
//

import SwiftUI

//备份切换试图
struct BackupsSwitchDialogView: View {
    let onDismiss: () -> Void
    
    var body: some View {
        PopupBottomView(title: "请选择备份模式") {
            VStack(spacing: 15) {
                HStack() {
                    VStack(alignment: .leading) {
                        Text("本地备份")
                            .font(.system(size: 16))
                            .foregroundStyle(.bgNormalText2)
                        Text("卸载会清空所有数据")
                            .font(.system(size: 12))
                            .foregroundStyle(.bgNormalText4)
                    }
                    Spacer()
                }.padding(.horizontal,15)
                    .frame(height: 80)
                    .background(BackupsManager.shared.isSameBackups(BackupsType.local) ? themeManager.themeColor.opacity(0.2) : .bgItemGray)
                    .cornerRadius(15)
                    .contentShape(Rectangle())
                    .onTapGesture {
                        BackupsManager.shared.backupsType = BackupsType.local
                        onDismiss()
                    }
                if !isExamine() {
//                    HStack() {
//                        VStack(alignment: .leading) {
//                            Text("阿里云盘备份")
//                                .font(.system(size: 16))
//                                .foregroundStyle(.bgNormalText2)
//                            Text("登陆自己的阿里云盘，自己的数据自己保管\n每天首次启动备份一次")
//                                .font(.system(size: 12))
//                                .foregroundStyle(.bgNormalText4)
//                        }
//                        Spacer()
//                    }.padding(.horizontal,15)
//                        .frame(height: 80)
//                        .background(BackupsManager.shared.isSameBackups(BackupsType.ali) ? themeManager.themeColor.opacity(0.2) : .bgItemGray)
//                        .cornerRadius(15)
//                        .contentShape(Rectangle())
//                        .onTapGesture {
//                            //                        backupsManager.backupsType = BackupsType.ali
//                            showToast("该功能暂未开放")
//                            onDismiss()
//                        }
                    HStack() {
                        VStack(alignment: .leading) {
                            Text("官方备份")
                                .font(.system(size: 16))
                                .foregroundStyle(.bgNormalText2)
                            Text("官方帮你保存备份，但是需要购买云容量包才能存储图片")
                                .font(.system(size: 12))
                                .foregroundStyle(.bgNormalText4)
                        }
                        Spacer()
                    }.padding(.horizontal,15)
                        .frame(height: 80)
                        .background(BackupsManager.shared.isSameBackups(BackupsType.cloud) ? themeManager.themeColor.opacity(0.2) : .bgItemGray)
                        .cornerRadius(15)
                        .contentShape(Rectangle())
                        .onTapGesture {
                            if userManager.isLogin() {
                                BackupsManager.shared.backupsType = BackupsType.cloud
                                onDismiss()
                            } else {
                                showLoginPopup()
                            }
                        }
                }
            }.padding(.top,15)
        }
    }
}

//#Preview {
//    BackupsSwitchDialogView()
//}
//定义预览提供者
struct BackupsSwitchDialogView_Previews: PreviewProvider {
    static var previews: some View {
        //使用预览共享配置
        configurePreviewEnvironment(for: BackupsSwitchDialogView(){})
    }
}
